import { ApiProperty } from '@nestjs/swagger'
import { Type } from 'class-transformer'
import { IsArray, IsNotEmpty, IsNumber, IsString } from 'class-validator'

export class CreateAppDto {
  @ApiProperty({ description: '首页资源标题' })
  @IsNotEmpty({ message: '标题不能为空' })
  @IsString()
  title: string

  @ApiProperty({ description: '封面图片Url' })
  @IsNotEmpty({ message: '封面图片不能为空' })
  @IsString()
  coverUrl: string

  @ApiProperty({ description: '关联内容(1-视频 2-图书 3-习题)' })
  @IsNotEmpty({ message: '关联内容不能为空' })
  @IsNumber()
  resourceType: number

  @ApiProperty({ description: '关联内容对应的系列', type: [[Number, Number]] })
  @IsNotEmpty({ message: '关联系列不能为空' })
  @IsArray()
  @Type(() => Array)
  seriesIds: [number, number][]

  @ApiProperty({ description: '是否显示', default: 1 })
  @IsNumber()
  visible: number

  @ApiProperty({ description: '排序', default: 1 })
  @IsNumber()
  sort: number
}
